package demo1;//牛客网:游游的重组偶数

import java.util.Scanner;
import java.io.*;
// 注意类名必须为 demo1.Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        int q = Integer.parseInt(br.readLine());
        while (q-- > 0) {
            int x = Integer.parseInt(br.readLine());
            if (x % 2 == 0) {
                pw.println(x);
            } else {
                char[] s = Integer.toString(x).toCharArray();
                int n = s.length;
                int i = 0;
                while (i < n) {
                    if ((s[i] - '0') % 2 == 0) {
                        char t = s[n - 1];
                        s[n - 1] = s[i];
                        s[i] = t;
                        break;
                    }
                    i++;
                }

                if (i == n) {
                    pw.println(-1);
                } else {
                    for (char ch : s) pw.print(ch);
                    pw.println();
                }
            }
        }
        pw.flush();
    }
}